#_*_ coding:utf-8 _*_
"""
    这是1个假的appiumserverdemo
    通过另外1个程序去守护进程他，如果这个程序被关闭了，另外1个程序去自动启动他。
"""
from socket import *
from time import ctime

def Demo_server():
    "一个demo，进程号是py.exe"
    HOST = '127.0.0.1'
    PORT = 4723
    ADDR = (HOST, PORT)
    server_socket = socket(AF_INET, SOCK_STREAM)  #固定写法
    server_socket.bind(ADDR)  #bind绑定地址
    server_socket.listen(5)
    while True:
        print('Waiting for connecting ......')
        tcpclientsocket, addr = server_socket.accept()
        print('Connected by ', addr)
        while True:
            data = tcpclientsocket.recv(1024)
            if not data:
                break
            print(data)
            data = input('I>')
            tcpclientsocket.send('[%s]%s' % (ctime(), data))
        tcpclientsocket.close()
    #server_socket.close()

Demo_server()
